home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 11
/
Amoszine 11 (Disk 2 of 2).adf
/
Loads_Of_Source.lha
/
filereq_creator.amos
/
filereq_creator.amosSourceCode
Wrap
AMOS Source Code
|
1996-03-06
|
16KB
|
811 lines
Set Buffer 10
' **********************
' *** FILE REQUESTER ***
' **********************
'
' A bit buggy and needs sorting I think!!! :(
' *** This Routine Lets You Create & Use A File-Requester, Instead Of The
' Normal AMOS One Provided.
' *** MAXIMUM FILES ALLOWED.
MXFILES=200
' *** MAXIMUM DEVICES ALLOWED.
MXDEVS=50
' *** DEFINE VARIABLES.
Dim FILE$(MXFILES),DEVS$(MXDEVS)
' *** MAKE VARIABLES GLOBAL.
Global AN,ED$,MXFILES,MXDEVS
Global PATH$,CPATH$,DEV$,POSF,POSD,FILE$(),DEVS$(),FIL$,DEV$,FILES,DEVS
' *** SET DEFAULT PATH, ONLY CHANGE PATH$ AND NOT CPATH$.
PATH$="RAM:"
CPATH$="Ram Disk:"
POSF=0
POSD=0
' *** CALL FILE REQUESTER.
FILREQ["SELECT A FILE."]
' *** PRINT SELECTED FILE.
Locate 0,0
Print "You selected :-"
Print
Pen 0
Paper 5
Print FIL$
Pen 2
Paper 1
' *** QUIT.
Direct
Procedure FILREQ[TITLE$]
' *** FILE REQUESTER VALUES.
' *** BY CHANGING THESE VALUES, YOU CAN DESIGN YOUR OWN FILE-REQUESTER.
_TITLE_X1=4
_TITLE_Y1=5
_TITLE_X2=635
_TITLE_Y2=23
_OK_X1=232
_OK_Y1=142
_OK_X2=332
_OK_Y2=158
_CANCEL_X1=4
_CANCEL_Y1=142
_CANCEL_X2=104
_CANCEL_Y2=158
_PARENT_X1=118
_PARENT_Y1=142
_PARENT_X2=218
_PARENT_Y2=158
_FILE_X1=4
_FILE_Y1=29
_FILE_X2=332
_FILE_Y2=120
_FILE_X=1
_FILE_Y=4
_FILE_LINES=10
_FILE_WIDTH=40
_FILE_UP_X1=336
_FILE_UP_Y1=29
_FILE_UP_X2=352
_FILE_UP_Y2=39
_FILE_DOWN_X1=336
_FILE_DOWN_Y1=148
_FILE_DOWN_X2=352
_FILE_DOWN_Y2=158
_FILE_SLIDER_X1=336
_FILE_SLIDER_Y1=41
_FILE_SLIDER_X2=352
_FILE_SLIDER_Y2=146
_DEVICE_X1=364
_DEVICE_Y1=29
_DEVICE_X2=614
_DEVICE_Y2=120+24
_DEVICE_X=46
_DEVICE_Y=4
_DEVICE_LINES=13
_DEVICE_WIDTH=30
_DEVICE_UP_X1=619
_DEVICE_UP_Y1=29
_DEVICE_UP_X2=635
_DEVICE_UP_Y2=39
_DEVICE_DOWN_X1=619
_DEVICE_DOWN_Y1=148
_DEVICE_DOWN_X2=635
_DEVICE_DOWN_Y2=158
_DEVICE_SLIDER_X1=619
_DEVICE_SLIDER_Y1=41
_DEVICE_SLIDER_X2=635
_DEVICE_SLIDER_Y2=146
_PATH_X1=4
_PATH_Y1=124
_PATH_X2=332
_PATH_Y2=138
_PATH_X=1
_PATH_Y=16
_PATH_WIDTH=40
_INFO_X1=364
_INFO_Y1=148
_INFO_X2=614
_INFO_Y2=158
' *** OPEN SCREEN FOR REQUESTER.
Screen Open 7,640,164,4,Hires
Flash Off
Curs Off
Cls 0
Pen 3
Paper 0
Palette $AAA,$FFF,$333,$FF0
' *** DRAW TITLE..
B[_TITLE_X1,_TITLE_Y1,_TITLE_X2,_TITLE_Y2,TITLE$,1]
' *** DRAW FILE PART.
B[_FILE_X1,_FILE_Y1,_FILE_X2,_FILE_Y2,"",0]
For LOP=_FILE_Y To _FILE_Y+_FILE_LINES
Locate _FILE_X,LOP
Print Space$(_FILE_WIDTH);
Next
B[_FILE_UP_X1,_FILE_UP_Y1,_FILE_UP_X2,_FILE_UP_Y2,"<",1]
B[_FILE_SLIDER_X1,_FILE_SLIDER_Y1,_FILE_SLIDER_X2,_FILE_SLIDER_Y2,"",0]
B[_FILE_DOWN_X1,_FILE_DOWN_Y1,_FILE_DOWN_X2,_FILE_DOWN_Y2,">",1]
' *** DRAW DEVICE PART.
B[_DEVICE_X1,_DEVICE_Y1,_DEVICE_X2,_DEVICE_Y2,"",0]
B[_DEVICE_UP_X1,_DEVICE_UP_Y1,_DEVICE_UP_X2,_DEVICE_UP_Y2,"<",1]
B[_DEVICE_SLIDER_X1,_DEVICE_SLIDER_Y1,_DEVICE_SLIDER_X2,_DEVICE_SLIDER_Y2,"",0]
B[_DEVICE_DOWN_X1,_DEVICE_DOWN_Y1,_DEVICE_DOWN_X2,_DEVICE_DOWN_Y2,">",1]
For Z=_DEVICE_Y To _DEVICE_Y+_DEVICE_LINES
Locate _DEVICE_X,Z
Print String$(" ",_DEVICE_WIDTH)
Next
' *** DRAW TEXT BOXES.
B[_PATH_X1,_PATH_Y1,_PATH_X2,_PATH_Y2,"",0]
Locate _PATH_X,_PATH_Y
Print String$(" ",_PATH_WIDTH)
' *** DRAW BUTTONS.
B[_CANCEL_X1,_CANCEL_Y1,_CANCEL_X2,_CANCEL_Y2,"Cancel",1]
B[_OK_X1,_OK_Y1,_OK_X2,_OK_Y2,"O.K",1]
B[_PARENT_X1,_PARENT_Y1,_PARENT_X2,_PARENT_Y2,"Parent",1]
' *** DRAW INFO BUTTON.
B[_INFO_X1,_INFO_Y1,_INFO_X2,_INFO_Y2,"",1]
' *** DRAW ANYTHING ELSE HERE.
Ink 2
Draw 0,163 To 639,163
' *** RESET FILE STRING.
FIL$=""
' *** CHECK IF DIRECTORY TAKEN BEFORE.
If PATH$<>CPATH$
Gosub _GET_DIR
Else
Gosub DISPF
Gosub DISPD
Gosub DISPP
End If
' *** MAIN LOOP.
Do
' *** SCROLL UP 1 FILE.
R[_FILE_UP_X1,_FILE_UP_Y1,_FILE_UP_X2,_FILE_UP_Y2]
If AN>0 and POSF>0
Dec POSF
Gosub DISPF
End If
' *** SCROLL DOWN 1 FILE.
R[_FILE_DOWN_X1,_FILE_DOWN_Y1,_FILE_DOWN_X2,_FILE_DOWN_Y2]
If AN>0 and POSF<FILES-_FILE_LINES
Inc POSF
Gosub DISPF
End If
' *** SCROLL UP 1 DEVICE.
R[_DEVICE_UP_X1,_DEVICE_UP_Y1,_DEVICE_UP_X2,_DEVICE_UP_Y2]
If AN>0 and POSD>0
Dec POSD
Gosub DISPD
End If
' *** SCROLL DOWN 1 DEVICE.
R[_DEVICE_DOWN_X1,_DEVICE_DOWN_Y1,_DEVICE_DOWN_X2,_DEVICE_DOWN_Y2]
If AN>0 and POSD<DEVS-_DEVICE_LINES
Inc POSD
Gosub DISPD
End If
' *** SELECT FILE.
For LOP=0 To _FILE_LINES
R[_FILE_X1,_FILE_Y1+(LOP*8),_FILE_X2,_FILE_Y1+(LOP*8)+8]
If AN
FIL$=FILE$(POSF+LOP)
Gosub CUT_FIL
Gosub DISPP
End If
Next LOP
' *** SELECT DEVICE..
For LOP=0 To _DEVICE_LINES
R[_DEVICE_X1,_DEVICE_Y1+(LOP*8),_DEVICE_X2,_DEVICE_Y1+(LOP*8)+8]
If AN
PATH$=DEVS$(POSD+LOP)
Gosub CUT_DEV
Gosub _GET_DIR
End If
Next LOP
' *** GRAB FILES SLIDER.
XSLI=_FILE_SLIDER_X1+2
YSLI=_FILE_SLIDER_Y1+2
SXSLI=_FILE_SLIDER_X2-_FILE_SLIDER_X1-2
SYSLI=_FILE_SLIDER_Y2-_FILE_SLIDER_Y1-2
LBANK=FILES+1
SYBANK=_FILE_LINES+1
PBANK=POSF+1
If FILES>_FILE_LINES
R[XSLI,SSL,XSLI+SXSLI,ESL]
If AN
MY=Y Screen(Y Mouse)
DY=MY-SSL
Repeat
MX=X Screen(X Mouse)
MY=Y Screen(Y Mouse)
MK=Mouse Key
Y=MY-YSLI-DY
POSF=(Y*(LBANK+1))/SYSLI+1
If POSF<0
POSF=0
End If
If POSF>LBANK-SYBANK
POSF=LBANK-SYBANK
End If
If POSF<>PBANK
PBANK=POSF
Gosub DISPF
End If
Until MK=0
End If
End If
' *** GRAB DEVICES SLIDER.
XSLI=_DEVICE_SLIDER_X1+2
YSLI=_DEVICE_SLIDER_Y1+2
SXSLI=_DEVICE_SLIDER_X2-_DEVICE_SLIDER_X1-2
SYSLI=_DEVICE_SLIDER_Y2-_DEVICE_SLIDER_Y1-2
LBANK=DEVS+1
SYBANK=_DEVICE_LINES+1
PBANK=POSD+1
If DEVS>_DEVICE_LINES
R[XSLI,SSL,XSLI+SXSLI,ESL]
If AN
MY=Y Screen(Y Mouse)
DY=MY-SSL
Repeat
MX=X Screen(X Mouse)
MY=Y Screen(Y Mouse)
MK=Mouse Key
Y=MY-YSLI-DY
POSD=(Y*(LBANK+1))/SYSLI+1
If POSD<0
POSD=0
End If
If POSD>LBANK-SYBANK
POSD=LBANK-SYBANK
End If
If POSD<>PBANK
PBANK=POSD
Gosub DISPD
End If
Until MK=0
End If
End If
' *** O.K BUTTON.
R[_OK_X1,_OK_Y1,_OK_X2,_OK_Y2]
If AN
If FIL$=""
FIL$=""
Else
FIL$=PATH$+FIL$
End If
Goto FIN
End If
' *** PARENT BUTTON.
R[_PARENT_X1,_PARENT_Y1,_PARENT_X2,_PARENT_Y2]
If AN
Gosub _PARENT
End If
' *** CANCEL BUTTON.
R[_CANCEL_X1,_CANCEL_Y1,_CANCEL_X2,_CANCEL_Y2]
If AN
FIL$=""
Goto FIN
End If
' *** EDIT REQUESTER PATH.
R[_PATH_X1,_PATH_Y1,_PATH_X2,_PATH_Y2]
If AN
ED[_PATH_X,_PATH_Y,"",PATH$,_PATH_WIDTH,120]
If Right$(PATH$,1)<>"/"
PATH$=PATH$+"/"
End If
PATH$=ED$
Gosub _GET_DIR
End If
'
Loop
' *** GET PARENT DIRECTORY.
_PARENT:
If Len(PATH$)>2
For LOP=Len(PATH$)-1 To 1 Step -1
A$=Mid$(PATH$,LOP,1)
If(A$="/") or(A$=":")
PATH$=Left$(PATH$,LOP)
Gosub _GET_DIR
Gosub DISPF
Exit
End If
Next LOP
End If
Return
' *** EXIT REQUESTER WITH SELECTED FILENAME.
FIN:
Screen Close 7
Pop Proc
' *** THIS CUTS A DEVICE INTO A DIR-ABLE NAME.
CUT_FIL:
For LOP=_FILE_WIDTH-9 To 1 Step -1
If Mid$(FIL$,LOP,1)<>" "
FIL$=Left$(FIL$,LOP)
Exit
End If
Next LOP
A$=Left$(FIL$,1)
FIL$=Mid$(FIL$,2)
If A$="*"
PATH$=PATH$+FIL$+"/"
FIL$=""
Gosub _GET_DIR
Gosub DISPF
End If
Return
' *** THIS CUTS A DEVICE INTO A DIR-ABLE NAME.
CUT_DEV:
For LOP=Len(PATH$) To 1 Step -1
If Mid$(PATH$,LOP,1)<>" "
PATH$=Left$(PATH$,LOP)
Exit
End If
Next LOP
PATH$=Mid$(PATH$,2)
If Right$(PATH$,1)<>":"
PATH$=PATH$+":"
End If
Return
' *** GET FILES & DEVICES LIST.
_GET_DIR:
If Not Exist(PATH$)
I$="PATH NOT FOUND !"
Gosub INFO
Wait 50
I$=""
Gosub INFO
PATH$=CPATH$
Gosub DISPP
Return
End If
' *** ERASE PREVIOUS DIRECTORY.
For LOP=0 To MXFILES
FILE$(LOP)=""
Next LOP
For LOP=0 To MXDEVS
DEVS$(LOP)=""
Next LOP
I$="READING DIRECTORY..."
Gosub INFO
Set Dir _FILE_WIDTH-8
FILES=0
FILE$(FILES)=Dir First$(PATH$)
While FILE$(FILES)<>""
Inc FILES
FILE$(FILES)=Dir Next$
Wend
Dec FILES
Set Dir _DEVICE_WIDTH-8
DEVS=0
DEVS$(DEVS)=Dev First$("")
While DEVS$(DEVS)<>""
Inc DEVS
DEVS$(DEVS)=Dev Next$
Wend
Dec DEVS
I$=""
Gosub INFO
CPATH$=PATH$
POSF=0
Gosub DISPF
Gosub DISPD
Gosub DISPP
Return
' *** DISPLAY PATH & FILENAME.
DISPP:
Locate _PATH_X,_PATH_Y
Print Space$(_PATH_WIDTH);
Locate _PATH_X,_PATH_Y
Print Left$(PATH$+FIL$,_PATH_WIDTH);
Return
' *** DISPLAY INFO.
INFO:
B[_INFO_X1+1,_INFO_Y1,_INFO_X2-1,_INFO_Y2,I$,2]
Return
' *** DISPLAY FILES.
DISPF:
For LOP=POSF To POSF+_FILE_LINES
Locate _FILE_X,LOP-POSF+_FILE_Y
If FILE$(LOP)<>""
Print FILE$(LOP);
Else
Print Space$(_FILE_WIDTH);
End If
Next LOP
' *** DISPLAY FILES SLIDER.
XSLI=_FILE_SLIDER_X1+2
YSLI=_FILE_SLIDER_Y1+2
SXSLI=_FILE_SLIDER_X2-_FILE_SLIDER_X1-3
SYSLI=_FILE_SLIDER_Y2-_FILE_SLIDER_Y1-2
LBANK=FILES+1
SYBANK=_FILE_LINES+1
PBANK=POSF+1
Cls 0,XSLI,YSLI To XSLI+SXSLI,YSLI+SYSLI
If LBANK>=SYBANK
SSL=YSLI+(SYSLI*(PBANK-1))/LBANK
ESL=Min(YSLI+SYSLI,SSL+(SYSLI*SYBANK)/LBANK)
Cls 3,XSLI,SSL To XSLI+SXSLI,ESL
End If
Return
' *** DISPLAY DEVICES:
DISPD:
For LOP=POSD To POSD+_DEVICE_LINES
Locate _DEVICE_X,LOP-POSD+_DEVICE_Y
If DEVS$(LOP)<>""
Print DEVS$(LOP);
Else
Print Space$(_DEVICE_WIDTH);
End If
Next LOP
' *** DISPLAY DEVICES SLIDER.
XSLI=_DEVICE_SLIDER_X1+2
YSLI=_DEVICE_SLIDER_Y1+2
SXSLI=_DEVICE_SLIDER_X2-_DEVICE_SLIDER_X1-3
SYSLI=_DEVICE_SLIDER_Y2-_DEVICE_SLIDER_Y1-2
LBANK=DEVS+1
SYBANK=_DEVICE_LINES+1
PBANK=POSD+1
Cls 0,XSLI,YSLI To XSLI+SXSLI,YSLI+SYSLI
If LBANK>=SYBANK
SSL=YSLI+(SYSLI*(PBANK-1))/LBANK
ESL=Min(YSLI+SYSLI,SSL+(SYSLI*SYBANK)/LBANK)
Cls 3,XSLI,SSL To XSLI+SXSLI,ESL
End If
Return
End Proc
Procedure ED[XX,YY,MSG$,ED$,SX,ML]
CCCC=0
MID=39-Int(SX/2)
If XX=0 and YY=0
Screen Open 7,640,38,8,Hires
Screen Display 7,,147,,
Curs Off
Flash Off
Cls 0
Pen 6
Paper 4
Palette $AA,$EEE,$DD,$77,$AA,$A0,$FE3,$44
CCCC=1
XX=MID
YY=3
B[40,(YY-3)*8,600,(YY-3)*8+12,MSG$,1]
B[(MID*8)-5,(8*(YY-1))+4,(MID*8)+(SX*8)+5,(8*(YY-1))+19,"",1]
B[(MID*8)-2,(8*(YY-1))+6,(MID*8)+(SX*8)+2,(8*(YY-1))+17,"",0]
Locate XX,YY
Ink 0
Bar 0,0 To 7,7
End If
Locate XX,YY
Print String$(" ",SX);
XC=0
MN=0
PX=0
L=Len(ED$)
If L>=SX
PX=L-SX
End If
Gr Writing 2
Do
Gosub _DED
GRX=X Curs*8
GRY=YY*8
Bar GRX,GRY To GRX+7,GRY+7
Repeat
A$=Inkey$
If CHK=1 and Timer>=1000
Bar GRX,GRY To GRX+7,GRY+7
Goto _END
End If
S=Scancode
If(CHK=1) and(A$<>"") and(Scancode=0)
Timer=0
End If
Until A$<>""
Bar GRX,GRY To GRX+7,GRY+7
F=1
If A$=Chr$(13)
Exit
End If
If A$=Chr$(27)
ED$="_Esc_"
Exit
End If
If S=65 and XC+PX>MN
ED$=Left$(ED$,XC+PX-1)+Mid$(ED$,PX+XC+1)
E=1
L=L-1
S=79
End If
If S=70 and XC+PX<L
ED$=Left$(ED$,XC+PX)+Mid$(ED$,PX+XC+2)
E=1
L=L-1
F=0
End If
If S=79 and PX+XC>MN
F=0
If XC=0
PX=PX-1
Else
XC=XC-1
End If
End If
If S=78 and PX+XC<L
F=0
If XC=SX
PX=PX+1
Else
XC=XC+1
End If
End If
If F
If A$>=" " and L<ML
ED$=Left$(ED$,PX+XC)+A$+Mid$(ED$,PX+XC+1)
L=L+1
If L>SX
If XC>=SX
PX=PX+1
Else
XC=XC+1
End If
Else
XC=XC+1
End If
End If
End If
Loop
Goto _END
_DED:
Locate XX,YY
Print Mid$(ED$,PX+1,SX);
If E
If X Curs<XX+SX
Print " ";
E=0
End If
End If
Locate Min(XX+XC,XX+SX-1),YY
Return
_END:
Gr Writing 1
If CCCC=1
Screen Close 7
End If
End Proc
Procedure R[X1,Y1,X2,Y2]
X3=X Screen(X Mouse)
Y3=Y Screen(Y Mouse)
M=Mouse Key
AN=0
If X3<X1 or X3>X2 or Y3<Y1 or Y3>Y2 or M=0
Pop Proc
End If
AN=M
End Proc
Procedure B[X1,Y1,X2,Y2,A$,IN]
Dim A$(5)
I=0
IO=0
B=0
While I<Len(A$)
I=Instr(A$,"|",I+1)
If I=0
I=Len(A$)+1
End If
A$(B)=Mid$(A$,IO+1,I-IO-1)
IO=I
Inc B
Wend
If IN=1
C1=1
C2=2
Else
C1=2
C2=1
End If
Ink 0
If IN=0 or IN=1
Bar X1,Y1 To X2,Y2
Ink C1
Box X1,Y1 To X2,Y2
Box X1+1,Y1 To X2-1,Y2
Ink C2
Polyline X1+1,Y2 To X2,Y2 To X2,Y1
Polyline X1+1,Y2 To X2-1,Y2 To X2-1,Y1+1
If IN=1
Plot X1+2,Y1+1,1
Plot X1+3,Y1+1,1
End If
End If
If IN=2
Bar X1+2,Y1+1 To X2-2,Y2-1
End If
H#=((Y2-Y1)-(B*8))/(B+1)
Y#=Y1+H#+7
For LOP=0 To B
WID=Text Length(A$(LOP))
X7=(((X2-X1)/2)+X1)-(WID/2)+1
Gr Writing 0
Ink 2,0
Text X7+1,Y#,A$(LOP)
Text X7-1,Y#,A$(LOP)
Text X7,Y#+1,A$(LOP)
Text X7,Y#-1,A$(LOP)
Ink 3,0
Text X7,Y#,A$(LOP)
Y#=Y#+8+H#
Gr Writing 1
Next LOP
End Proc